﻿@using Lib.core;
@using Lib.helper;

@using Bll;
@using Model;
@using Model.User;
@{
    Layout = null;

    var model = GetModel<UserModel>("model");
}

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- header page -->
    @Html.Partial(IncludePath("header"))
</head>

<body>
    @Html.Partial(IncludePath("body_top"))

    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="tombstone">
                    <div class="well">发送给：@(model.NickName)</div>
                    <div style="margin: 20px 0;">
                        <textarea rows="5" cols="20" id="msg" class="form-control" style="height: 300px;"></textarea>
                    </div>
                    <div class="right" style="padding:30px 0;">
                        <button class="btn btn-primary btn-send" data-to="@(model.UID)">发送</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            $('.btn-send').click(function () {
                var id = $(this).attr('data-to');
                var msg = $('#msg').val();
                if (msg == null || msg == '') { alert('请输入内容'); return; }
                postJson('/user/sendmessageaction/', {
                    to: id,
                    msg: msg
                }, function (res) {
                    if (res && res.success) {
                        alert('发送成功');
                        window.location.reload();
                    }
                    else {
                        alert(res.msg);
                    }
                });
            });
        });
    </script>

    @Html.Partial(IncludePath("body_bottom"))
</body>
</html>
